<%@ page language="java" import="dao.*" pageEncoding="UTF-8" %>
 <%@ page language="java" import="java.util.*" %>
 <%@page import="util.*" %>
 <%@ include file="head.jsp" %>


<div style="padding: 10px" class="admin-content">
    <%
    String orderby = util.Request.get("order", "id"); // 获取搜索框中的排序字段、默认为发布时间
    String sort = util.Request.get("sort", "desc"); // 获取搜索框中的排序类型、默认为倒序
    
    String where = " 1=1 "; // 防止sql 搜索条件为： where and a=b 这样的错误
    
    // 以下是检测搜索框中是否填写了或者选择了什么，则写入sql 语句中
    
    if (request.getParameter("xuejixinxiid") != null && !"".equals(request.getParameter("xuejixinxiid"))) {
        where += " AND xuejixinxiid='" + request.getParameter("xuejixinxiid") + "' ";
    }
    if (request.getParameter("xuehao") != null && !"".equals(request.getParameter("xuehao"))) {
        where += " AND xuehao LIKE '%" + request.getParameter("xuehao") + "%'";
    }
    if (request.getParameter("xueqi") != null && !"".equals(request.getParameter("xueqi"))) {
        where += " AND xueqi ='" + request.getParameter("xueqi") + "'";
    }
    if (request.getParameter("banji") != null && !"".equals(request.getParameter("banji"))) {
        where += " AND banji ='" + request.getParameter("banji") + "'";
    }
    if (request.getParameter("biandongzhuangtai") != null && !"".equals(request.getParameter("biandongzhuangtai"))) {
        where += " AND biandongzhuangtai ='" + request.getParameter("biandongzhuangtai") + "'";
    }
    if (request.getParameter("biandongyuanyin") != null && !"".equals(request.getParameter("biandongyuanyin"))) {
        where += " AND biandongyuanyin LIKE '%" + request.getParameter("biandongyuanyin") + "%'";
    }
    
    List<Map> list = Query.make("xuejibiandong").where(where).order(orderby + " " + sort).page(15);
    %>


    <div class="panel panel-default">
        <div class="panel-heading">
            <span class="module-name"> 学籍变动 </span>
            <span>列表</span>
        </div>
        <div class="panel-body">
            <div class="pa10 bg-warning">
                <form class="form-inline" id="formSearch" action="?">
                    <!-- form 标签开始 -->

                    <div class="form-group">
                        <i class="glyphicon glyphicon-search"></i>
                    </div>

                    <div class="form-group">
                        学号

                        <input type="text" class="form-control" style="" name="xuehao" value="<%= request.getParameter("xuehao") !=null ? request.getParameter("xuehao") : "" %>" />
                    </div>
                    <div class="form-group">
                        学期

                        <select class="form-control class_xueqi23" data-value="<%= request.getParameter("xueqi") !=null ? request.getParameter("xueqi") : "" %>" id="xueqi" name="xueqi">
                            <option value="">请选择</option>
                            <% List<Map> select = new CommDAO().select("SELECT * FROM xueqixinxi ORDER BY id desc"); %>
 <% for (Map m : select) { %>

                            <option value="<%= m.get("id") %>"><%= m.get("xueqimingcheng") %></option>
                            <%} %>

                        </select>
                        <script>
                            $(".class_xueqi23").val($(".class_xueqi23").attr("data-value"));
                        </script>
                    </div>
                    <div class="form-group">
                        班级

                        <select class="form-control class_banji24" data-value="<%= request.getParameter("banji") !=null ? request.getParameter("banji") : "" %>" id="banji" name="banji">
                            <option value="">请选择</option>
                            <% select = new CommDAO().select("SELECT * FROM banjixinxi ORDER BY id desc"); %>
 <% for (Map m : select) { %>

                            <option value="<%= m.get("id") %>"><%= m.get("banjimingcheng") %></option>
                            <%} %>

                        </select>
                        <script>
                            $(".class_banji24").val($(".class_banji24").attr("data-value"));
                        </script>
                    </div>
                    <div class="form-group">
                        变动状态

                        <select
                            class="form-control class_biandongzhuangtai25"
                            data-value="<%= request.getParameter("biandongzhuangtai") !=null ? request.getParameter("biandongzhuangtai") : "" %>"
                            data-rule-required="true"
                            data-msg-required="请填写变动状态"
                            id="biandongzhuangtai"
                            name="biandongzhuangtai"
                        >
                            <option value="">请选择</option>
                            <option value="在籍">在籍</option>
                            <option value="转学">转学</option>
                            <option value="毕业">毕业</option>
                            <option value="开除">开除</option>
                        </select>
                        <script>
                            $(".class_biandongzhuangtai25").val($(".class_biandongzhuangtai25").attr("data-value"));
                        </script>
                    </div>
                    <div class="form-group">
                        变动原因

                        <input type="text" class="form-control" id="biandongyuanyin" name="biandongyuanyin" value="<%= request.getParameter("biandongyuanyin") !=null ? request.getParameter("biandongyuanyin") : "" %>" />
                    </div>
                    <select class="form-control" name="order" id="orderby">
                        <option value="id">按发布时间</option>
                    </select>
                    <select class="form-control" name="sort" id="sort">
                        <option value="desc">倒序</option>
                        <option value="asc">升序</option>
                    </select>
                    <script>
                        $("#orderby").val("<%= orderby %>");
                        $("#sort").val("<%= sort %>");
                    </script>
                    <button type="submit" class="btn btn-default">搜索</button>

                    <button type="button" class="btn btn-default" onclick="exportXls()">导出</button>
                    <script>
                        function exportXls() {
                            var param = $("#formSearch").serialize();
                            var url = "xuejibiandong_export.jsp";
                            url += (url.indexOf("?") == -1 ? "?" : "&") + param;
                            location.href = url;
                        }
                    </script>

                    <!--form标签结束-->
                </form>
            </div>

            <div class="list-table">
                <table width="100%" border="1" class="table table-list table-bordered table-hover">
                    <thead>
                        <tr align="center">
                            <th width="60" data-field="item">序号</th>
                            <th>学号</th>
                            <th>姓名</th>
                            <th>入学时间</th>
                            <th>学期</th>
                            <th>班级</th>
                            <th>头像</th>
                            <th>变动状态</th>
                            <th>变动原因</th>
                            <th>教师</th>
                            <th>变动时间</th>
                            <th width="220" data-field="handler">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <%
                        int i = 0;
                        for (Map map : list) {
                            i++;
                        %>

                        <tr id="<%= map.get("id") %>" pid="">
                            <td width="30" align="center">
                                <label> <%= i %> </label>
                            </td>
                            <td><%= map.get("xuehao") %></td>
                            <td><%= map.get("xingming") %></td>
                            <td><%= map.get("ruxueshijian") %></td>
                            <td><% Map mapxueqixinxi22 = new CommDAO().find("SELECT xueqimingcheng,id FROM xueqixinxi where id='" + map.get("xueqi") + "'"); %>
<%= mapxueqixinxi22.get("xueqimingcheng") %></td>
                            <td><% Map mapbanjixinxi23 = new CommDAO().find("SELECT banjimingcheng,id FROM banjixinxi where id='" + map.get("banji") + "'"); %>
<%= mapbanjixinxi23.get("banjimingcheng") %></td>
                            <td><% if ("".equals(map.get("touxiang"))) { %>
-<%} else { %><img width="100" src="<%= map.get("touxiang") %>" /><%} %>
</td>
                            <td><%= map.get("biandongzhuangtai") %></td>
                            <td><%= map.get("biandongyuanyin") %></td>
                            <td><%= map.get("caozuoren") %></td>
                            <td><%= Info.subStr(map.get("addtime") , 19 , "") %></td>
                            <td align="center">
                                <a href="xuejibiandong_detail.jsp?id=<%= map.get("id") %>">详情</a>

                                <a href="xuejibiandong_updt.jsp?id=<%= map.get("id") %>">编辑</a>

                                <a href="xuejibiandong.jsp?a=delete&id=<%= map.get("id") %>" onclick="return confirm('确定要删除？')">删除</a>
                                <!--qiatnalijne-->
                            </td>
                        </tr>
                        <%} %>

                    </tbody>
                </table>
            </div>

            ${page.info}
        </div>
    </div>
</div>
<%@ include file="foot.jsp" %>

